package com.woniuxy01;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;

/**
 * @author 作者
 * @create 2025-11-10 10:16
 */
public class Test01 {
    public static void main(String[] args) {
        ArrayList<Student> students=new ArrayList<>();
        students.add(new Student(1,"zs",11));
        students.add(new Student(2,"ls",12));
        students.add(new Student(3,"ww",13));
        students.add(new Student(1,"zs",11));
        students.stream()
                .distinct() //底层也是使用hashCode和equals
                .forEach(System.out::println);
    }

    private static void test06() {
        HashSet<Student> students=new HashSet<>();
        students.add(new Student(1,"zs",11));
        students.add(new Student(2,"ls",12));
        students.add(new Student(3,"ww",13));
        students.add(new Student(1,"zs",11));
        students.forEach(System.out::println);
        Student s1 = new Student(1, "zs", 11);
        Student s2 = new Student(1, "zs", 11);
        System.out.println(s1==s2);
        System.out.println(s1.equals(s2));
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
    }

    private static void test05() {
        HashSet<String> strs=new HashSet<>();
        strs.add("ddd");
        strs.add("ccc");
        strs.add("Aa");
        strs.add("BB");
        System.out.println(strs);
    }

    private static void test04() {
        Student s1 = new Student(1, "zs", 11);
        Student s2 = new Student(1, "zs", 11);
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());

        String str1=new String("Aa");
        String str2=new String("BB");
        System.out.println(str1.hashCode());
        System.out.println(str2.hashCode());

        System.out.println('a' & 0xff);
        System.out.println(97 & 0xff);
    }

    private static void test03() {
        HashSet<Student> students=new HashSet<>();
        students.add(new Student(1,"zs",11));
        students.add(new Student(2,"ls",12));
        students.add(new Student(3,"ww",13));
        students.add(new Student(1,"zs",11));
        students.forEach(System.out::println);
        Student s1 = new Student(1, "zs", 11);
        Student s2 = new Student(1, "zs", 11);
        System.out.println(s1==s2);
        System.out.println(s1.equals(s2));
    }

    private static void test02() {
        HashSet<String> strs=new HashSet();
        strs.add("aaa");
        strs.add("bbb");
        strs.add("ccc");
        strs.add("aaa");
        strs.add("bbb");
        strs.add("ccc");
        strs.forEach(System.out::println);
    }

    private static void test01() {
        LinkedList<String> strs=new LinkedList<>();
        strs.add("aaa");
        strs.add("ccc");
        strs.add("bbb");
        strs.add("ddd");
        strs.forEach(System.out::println);
    }
}
